﻿using System.Linq;
using easyccms.BusinessLayer.Entities;

namespace easyccms.BusinessLayer.Repositories
{
    /// <summary>
    /// Interface for managing entity instances.
    /// </summary>
    public interface IRepository<T> where T : Entity
    {
        /// <summary>
        /// Loads the Entity from the back-end store.
        /// </summary>
        /// <param name="id">The ID of the Entity to load.</param>
        /// <returns>The Entity.</returns>
        T Load(int id);

        /// <summary>
        /// Saves the supplied Entity to the persistence medium.
        /// </summary>
        /// <param name="entity">The Entity to save.</param>
        void Save(T entity);

        /// <summary>
        /// Deletes the supplied Entity from the persistence medium.
        /// </summary>
        /// <param name="entity">The Entity to delete.</param>
        void Delete(T entity);

        /// <summary>
        /// The full list of Entities.
        /// </summary>
        IQueryable<T> All { get; }

        IUnitOfWork GetUnitOfWork();
    }
}
